<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>测测你七夕会发生的五件事</title>
    <meta name=referrer content=never>
    <link rel="stylesheet" type="text/css" href="__STATIC__/doclist/css/bootstrap.min.css">
    <link rel="stylesheet" href="__STATIC__/doclist/js/bootstrap/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <script src="__STATIC__/doclist/js/jquery-min.js"></script>
    <script src="__STATIC__/doclist/js/jquery.qrcode.min.js"></script>
<!--     <script type="text/javascript">
        document.write('<script type="text/javascript" src="//wap.cmread.com/rbc/t/content/repository/ues/js/s109/vconsole.js"><\/script>');
        document.write('<script type="text/javascript">var vConsole=new VConsole();<\/script>');
    </script> -->
</head>

<body ontouchstart="">
    
    <style>
        .return-con {
            -webkit-text-size-adjust: none;
            display: flex;
            line-height: 45px;
            position: fixed;
            top: 0px;
            left: 0px;
            width: 100%;
            border-bottom: .01333rem solid #d0d0d0;
            background: #f6f6f6;
            z-index: 9999999999999999;
        }

        .return-btn {
            line-height: 45px;
            padding-left: 0.3rem;
            color: #4a4a4a;
            display: flex;
            font-size: 16px;
            padding-right: 13px;
            -webkit-box-align: center;
            -webkit-align-items: center;
            align-items: center;
            -webkit-box-pack: center;
            -webkit-justify-content: center;
            justify-content: center;
            position: relative;
        }

        .return-btn::before {
            content: "";
            position: absolute;
            top: 0;
            left: .2rem;
            bottom: 0;
            margin: auto;
            width: 9px;
            height: 16px;
            background: url('') 50% no-repeat;
            background-size: .048rem auto;
        }

        .ts-btn {
            line-height: 45px;
            display: flex;
            position: fixed;
            right: 25px;
        }

        .ts-btn a {
            color: #4a4a4a;
            text-decoration: none;
            font-size: 16px;
        }
    </style>

    <div class="return-con">
        <div class="return-btn" onclick="history.go(-1);">返回</div>
        <div class="ts-btn">
            <a href="http://cn.lcbygroup.com/weixin110/index.shtml">投诉</a>
        </div>
    </div>
    <div style="height:45px;"></div>

    <style>
        .modal {
            background: rgba(0, 0, 0, 1);
            position: fixed;
            width: 100%;
            height: 100%;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            display: none;
            z-index: 101;
            color: #4a4a4a;
            text-align: center
        }

        .modal .modal-inner {
            width: 13rem;
            background-size: 100%;
            border-radius: 20px;
            padding: 0.5rem 0 0;
            top: 30%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
            position: absolute;
            height: 9rem
        }

        .modal .title {
            font-size: .453rem;
            margin-bottom: .3rem
        }

        .modal .title span {
            color: #ce0b24
        }

        .modal p {
            font-size: 0.9rem;
            line-height: 1.5;
            margin: 0;
            color: #fff;
            text-align: center;
            text-shadow: 0 1px 3px rgb(0, 0, 0)
        }

        .modal img {
            width: 8rem;
            margin: 0.6rem 0 .4rem;
            vertical-align: middle
        }

        .modal .close-btn {
            width: 40px;
            height: 40px;
            position: absolute;
            border: 1px solid #eaeaea;
            border-radius: 50%;
            bottom: -120px;
            left: 50%;
            margin-left: -20px
        }

        .modal .close-btn:before,
        .modal .close-btn:after {
            content: '';
            width: 25px;
            height: 1px;
            background: #eaeaea;
            top: 50%;
            display: block;
            position: absolute;
            left: 6px
        }

        .modal .close-btn:before {
            -webkit-transform: rotate(45deg);
            transform: rotate(45deg)
        }

        .modal .close-btn:after {
            -webkit-transform: rotate(-45deg);
            transform: rotate(-45deg)
        }

        .modal .link {
            display: none;
            margin-top: 1rem;
            width: 130px;
            font-size: 18px;
            text-align: center;
            font-weight: normal;
            border: 1px solid #4a4a4a;
            line-height: 36px
        }

        .modal.random .link {
            display: inline-block
        }

        .modal.random .qrcode {
            display: none
        }
        .inputbox{
            padding:10px;
        }
        .tijiao{
            height:35px;padding:0px 0;margin-top: 5px;font-size: 16px;
        }
    </style>


    <img src="__STATIC__/images/cover.png" id="show_img" width="100%" style="margin:0;">
    <div class="ui-form ui-border-t inputbox">
        <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">姓名</span>
            <input type="text" class="form-control" id="name" placeholder="输入您的姓名" aria-describedby="basic-addon1">
        </div>
        <div class="ui-btn-wrap">
            <button type="button" class="btn btn-primary btn-lg btn-block tijiao">确认提交</button>
        </div>
    </div>

    <div style="text-align: center;display: none" id="qrPic"></div>
    <input type="hidden" id="codeUrl" name="codeUrl" value="jebchjebch" />
    <!-- <img src="" id="myImg" /> -->

    <script type="text/javascript">
        var showImg = document.getElementById("show_img");
        var loadimg = '__STATIC__/doclist/images/loading.svg'
        $(function(){
            $('.tijiao').click(function(){
                var name = $('#name').val();
                var oldimg = showImg.src;
                showImg.src = loadimg;
                $.get('/index/game/simg?name='+name,function(res){
                    res = JSON.parse(res);
                    setImgText({
                        name:name,
                        text:res.data,
                        bgimg:'__STATIC__/images/bk.jpg',
                        bgw:674,
                        bgh:735,
                        link: location.origin + '/index/game',
                        success:function(url){
                            $('.inputbox').hide();
                            showImg.src = url;
                        },
                        error:function(err){
                            showImg.src = oldimg;
                        }
                    });
                    
                });
            });
        })
        function setImgText(data) {
            var c = document.createElement('canvas');
            // var ewmimg = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data='+data.link
            c.width = data.bgw;
            c.height = data.bgh;
            var cxt = c.getContext("2d");
            var img = new Image();
            img.setAttribute("crossOrigin", 'Anonymous')
            img.onload = function () {
                cxt.drawImage(img, 0, 0, data.bgw, data.bgh);
                cxt.save();
                cxt.font = "30px Arial";
                cxt.textBaseline = 'middle';
                cxt.textAlign = 'center';
                cxt.fillText(data.name, c.width / 2, 100);
                cxt.textAlign = 'left';
                data.text.forEach(function(item,index){
                    cxt.fillText((index+1)+'.'+item, 70, 220 + ( index*70));
                })

                var ewm = new Image();
                var ewmimg = qr(data.link);
                ewm.setAttribute("crossOrigin", 'Anonymous')
                console.log(ewmimg);
                ewm.onload = function(){
                    cxt.drawImage(ewm, 65, 570, 92, 92);
                    cxt.save();
                    var tempSrc = c.toDataURL("image/png");
                    data.success(tempSrc);
                }
                ewm.src = ewmimg
            };
            img.src = data.bgimg;


        }
        function qr(link) {
            $("#qrPic").empty();
            var str = toUtf8(link);
            $("#qrPic").qrcode({
                render: "canvas",
                width: 400,
                height: 400,
                text: str
            });

            $("canvas").attr("id", "erw");
            var canvas = document.getElementById('erw');
            var context = canvas.getContext('2d');
            var strDataURI = canvas.toDataURL();
            return strDataURI;
        }
        function toUtf8(str) {
            var out, i, len, c;
            out = "";
            len = str.length;
            for (i = 0; i < len; i++) {
                c = str.charCodeAt(i);
                if ((c >= 0x0001) && (c <= 0x007F)) {
                    out += str.charAt(i);
                } else if (c > 0x07FF) {
                    out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                    out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
                } else {
                    out += String.fromCcodeharCode(0xC0 | ((c >> 6) & 0x1F));
                    out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
                }
            }
            return out;
        }
    </script>
    <script src="__STATIC__/doclist/js/bootstrap/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>

</html>